 <div class="modal-dialog">
		      <div class="modal-content">
		         <div class="modal-header">
		            <button type="button" class="close" 
		               data-dismiss="modal" aria-hidden="true">
		                  &times;
		            </button>
		            <h4 class="modal-title" id="myModalLabel">
		               	设置角色权限
		            </h4>
		         </div>
		         <div class="modal-body" id="permissionDialog">
		         	<input type="hidden" id="roleId" value="${id!}"/>
		            <ul id="menuTree" class="ztree"></ul>
		         </div>
		         <div class="modal-footer">
		            <button type="button" class="btn btn-warning" 
		               data-dismiss="modal">关闭
		            </button>
		            <button type="button" class="btn btn-primary" id="setPermissionSubmitBtn" authCode="32">
		               	设置保存
		            </button>
		         </div>
	 </div><!-- /.modal-content -->
	</div>
	<script>
	(function($){
		var setting = {
				check: {
					enable: true,
					chkboxType: { "Y": "p", "N": "s" }
				},
				data: {
					simpleData: {
						enable: true
					}
				},
				async: {
					enable: true,
					url:"system/queryPermission?roleId="+$("#permissionDialog #roleId").val(),
					autoParam:["id"],
					dataFilter: filter
				}
			};

			function filter(treeId, parentNode, childNodes) {
				if (!childNodes) return null;
				for (var i=0, l=childNodes.length; i<l; i++) {
					childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
				}
				return childNodes;
			}
			
			function updatePermission(roleId,permissions){
				$.ajax({
	                type: "post",
	                url: "system/updatePermission",
	                data: "roleId="+roleId+"&menuIds="+permissions,
	                dataType: "json",
	                success: function(data){
	                	if(data.code==0){
	                		$("#permissionset_dialog").modal("hide");
	                	}else{
	                		alert("修改权限错误");
	                	}
	                }
	        	});
			}
			$(document).ready(function(){
				var treeObj = $.fn.zTree.init($("#menuTree"), setting);
				$("#setPermissionSubmitBtn").click(function(){
					var treeIds = [];
					var nodes = treeObj.getCheckedNodes(true);
					for(var i=0;i<nodes.length;i++){
						treeIds.push(nodes[i].id);
					}
					var treeIdsStr = treeIds.join(",");
					var roleId = $("#permissionDialog #roleId").val();
					updatePermission(roleId,treeIdsStr);
				});
			});
	})($);
	
	</script>